home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / lang / sofa.lha / sofa / smalleiffel / lib_se / run_feature_11.e < prev    next >
Text File  |  2000-03-25  |  6KB  |  233 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr
  4. --                       http://SmallEiffel.loria.fr
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
  11. -- for  more  details.  You  should  have  received a copy of the GNU General
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class RUN_FEATURE_11
  17.    --
  18.    -- Wrapped some function called via the Precursor construct.
  19.    --
  20. inherit RUN_FEATURE redefine fall_down end;
  21.  
  22. creation {E_PRECURSOR_FUNCTION} make
  23.  
  24. feature
  25.  
  26.    base_feature: EFFECTIVE_ROUTINE;
  27.  
  28.    arguments: FORMAL_ARG_LIST;
  29.  
  30.    result_type: TYPE;
  31.  
  32.    require_assertion: RUN_REQUIRE;
  33.  
  34.    local_vars: LOCAL_VAR_LIST;
  35.  
  36.    routine_body: COMPOUND;
  37.  
  38.    rescue_compound: COMPOUND;
  39.  
  40.    ensure_assertion: E_ENSURE;
  41.  
  42.    is_deferred: BOOLEAN is false;
  43.  
  44.    is_static: BOOLEAN is false;
  45.  
  46.    can_be_dropped: BOOLEAN is false;
  47.  
  48.    is_once_procedure: BOOLEAN is false;
  49.  
  50.    is_once_function: BOOLEAN is
  51.      -- True when some once function is wrapped.
  52.       local
  53.      once_function: ONCE_FUNCTION;
  54.       do
  55.      once_function ?= base_feature;
  56.      Result := once_function /= Void;
  57.       end;
  58.  
  59.    is_pre_computable: BOOLEAN is
  60.       do
  61.      if is_once_function then
  62.         Result := once_routine_pool.is_pre_computable(Current);
  63.      end;
  64.       end;
  65.  
  66.    fall_down is
  67.       do
  68.       end;
  69.  
  70.    static_value_mem: INTEGER is
  71.       do
  72.       end;
  73.  
  74.    afd_check is
  75.       do
  76.          routine_afd_check;
  77.       end;
  78.  
  79.    mapping_c is
  80.       local
  81.          tmp_expanded_idx: INTEGER;
  82.       do
  83.      if is_pre_computable then
  84.             once_routine_pool.c_put_o_result(Current);        
  85.      else
  86.         tmp_expanded_idx := cpp.se_tmp_open(Current);
  87.         default_mapping_function;
  88.         if tmp_expanded_idx >= 0 then
  89.            cpp.se_tmp_close(tmp_expanded_idx);
  90.         end;
  91.      end;
  92.       end;
  93.  
  94.    c_define is
  95.       local
  96.      once_wrapper: BOOLEAN;
  97.       do
  98.      cpp.incr_precursor_routine_count;
  99.      once_wrapper := is_once_function;
  100.      if once_wrapper then
  101.         once_routine_pool.c_define_o_result(Current);
  102.      end;
  103.      if not is_pre_computable then
  104.         if once_wrapper then
  105.            once_routine_pool.c_define_o_flag(Current);
  106.         end;
  107.         define_prototype;
  108.         if once_wrapper then
  109.            once_routine_pool.c_test_o_flag(Current);
  110.         end;
  111.         c_define_opening;
  112.         if routine_body /= Void then
  113.            routine_body.compile_to_c;
  114.         end;
  115.         c_define_closing;
  116.         if once_wrapper then
  117.            once_routine_pool.c_return_o_result(Current);
  118.         else
  119.            cpp.put_string(fz_15);
  120.         end;
  121.         c_frame_descriptor;
  122.      end;
  123.       end;
  124.  
  125. feature {RUN_CLASS}
  126.  
  127.    jvm_field_or_method is
  128.       do
  129.          jvm.add_method(Current);
  130.       end;
  131.  
  132. feature
  133.  
  134.    mapping_jvm is
  135.       do
  136.          routine_mapping_jvm;
  137.       end;
  138.  
  139. feature {JVM}
  140.  
  141.    jvm_define is
  142.       do
  143.          method_info_start;
  144.          jvm_define_opening;
  145.          if routine_body /= Void then
  146.             routine_body.compile_to_jvm;
  147.          end;
  148.          jvm_define_closing;
  149.          result_type.jvm_push_local(jvm_result_offset);
  150.          result_type.run_type.jvm_return_code;
  151.          method_info.finish;
  152.       end;
  153.  
  154. feature {NONE}
  155.  
  156.    update_tmp_jvm_descriptor is
  157.       do
  158.          routine_update_tmp_jvm_descriptor;
  159.       end;
  160.  
  161. feature {E_PRECURSOR}
  162.  
  163.    collect_c_tmp is
  164.       do
  165.          if result_type.is_user_expanded then
  166.             if result_type.is_dummy_expanded then
  167.             else
  168.                cpp.se_tmp_add(Current);
  169.             end;
  170.          end;
  171.       end;
  172.  
  173. feature {ADDRESS_OF_POOL}
  174.  
  175.    address_of_c_define(caller: ADDRESS_OF) is
  176.       do
  177.       end;
  178.  
  179. feature {ADDRESS_OF}
  180.  
  181.    address_of_c_mapping is
  182.       do
  183.       end;
  184.  
  185. feature {NONE}
  186.  
  187.    compute_use_current is
  188.       do
  189.          std_compute_use_current;
  190.       end;
  191.  
  192.    initialize is
  193.       do
  194.          arguments := base_feature.arguments;
  195.          if arguments /= Void then
  196.             if not arguments.is_runnable(current_type) then
  197.                !!arguments.with(arguments,current_type);
  198.             end;
  199.          end;
  200.          result_type := base_feature.result_type.to_runnable(current_type);
  201.          local_vars := base_feature.local_vars;
  202.          if local_vars /= Void then
  203.             local_vars := local_vars.to_runnable(current_type);
  204.          end;
  205.          routine_body := base_feature.routine_body;
  206.          if routine_body /= Void then
  207.             routine_body := routine_body.to_runnable(current_type);
  208.          end;
  209.          if run_control.require_check then
  210.             require_assertion := run_require;
  211.          end;
  212.          if run_control.ensure_check then
  213.             ensure_assertion := run_ensure;
  214.          end;
  215.          rescue_compound := base_feature.rescue_compound;
  216.          if rescue_compound /= Void then
  217.             exceptions_handler.set_used;
  218.             rescue_compound := rescue_compound.to_runnable(current_type);
  219.          end;
  220.      if is_once_function then
  221.         once_routine_pool.register_function(Current);
  222.      end;
  223.       end;
  224.  
  225.    compute_stupid_switch(r: ARRAY[RUN_CLASS]) is
  226.       do
  227.          std_compute_stupid_switch(r);
  228.       end;
  229.  
  230.    stupid_switch_comment: STRING is "SSPRF11";
  231.  
  232. end -- RUN_FEATURE_11
  233.